Repository navigation
Conversation
Add a loop toggle and repeated keyframe curves to the Keyframes panel. Show authored endpoint values in controls and provide an action to match the first keyframe value. Hide looping controls and guard loop APIs with older MLT versions.
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Loop edits can race playback and discard existing keyframes, while loop-display and interaction defects also remain.
6 open issues
Synchronize loop edits to avoid playback races · New Preserve animation keys and loop state when editing properties · New Notify LoopRole when an existing animation's loop state changes · New Draw loop cycles across the visible viewport · New Prevent ghost-marker double-clicks from adding keyframes · New Keep preview overlays on evaluated values · New
What changed in this PR
Adds per-parameter animation looping to Shotcut’s keyframe editor using MLT’s loop support, with controls for managing loop endpoints and visualizing repeated animation.
Changes:
- Add Loop toggles and shaded ghost keyframes and curves.
- Add a “Match First Keyframe Value” context-menu action.
- Extend the parameter model, undo tracking, and filter value reads to support looping.
| File | Description |
|---|---|
src/qmltypes/qmlfilter.h |
Declare the endpoint-value read helper. |
src/qmltypes/qmlfilter.cpp |
Support authored endpoint values in typed reads and comparisons. |
src/qml/views/keyframes/ParameterHead.qml |
Add the per-parameter Loop button. |
src/qml/views/keyframes/keyframes.qml |
Bind loop state to headers and parameter tracks. |
src/qml/views/keyframes/KeyframeParameter.qml |
Draw repeated curves and ghost markers. |
src/models/keyframesmodel.h |
Expose loop support, state, and editing methods. |
src/models/keyframesmodel.cpp |
Implement loop toggling, endpoint matching, and undo integration. |
src/docks/keyframesdock.cpp |
Register and display the endpoint-matching action. |
Review effort: Balanced
Comment on lines
+1258
to
+1276
| Mlt::Animation animation = m_filter->getAnimation(key); | ||
| if (!animation.is_valid() || animation.key_count() < 2) | ||
| continue; | ||
| const int lastIndex = animation.key_count() - 1; | ||
| const int lastFrame = animation.key_get_frame(lastIndex); | ||
| const auto lastType = animation.key_get_type(lastIndex); | ||
| const QString value = m_filter->get(key, animation.key_get_frame(0)); | ||
| if (m_filter->service().anim_set(qUtf8Printable(key), | ||
| qUtf8Printable(value), | ||
| lastFrame, | ||
| m_filter->duration())) { | ||
| LOG_ERROR() << "Failed to match keyframe value" << key; | ||
| } else if (animation.key_set_type(lastIndex, lastType)) { | ||
| LOG_ERROR() << "Failed to restore keyframe type" << key; | ||
| } else { | ||
| animation.interpolate(); | ||
| m_filter->service().get(qUtf8Printable(key)); | ||
| m_filter->updateUndoCommand(key); | ||
| } |
Comment on lines
+369
to
+372
| case LoopRole: { | ||
| #if LIBMLT_VERSION_INT >= ((7 << 16) + (43 << 8)) | ||
| Mlt::Animation animation = m_filter->getAnimation(m_propertyNames[index.row()]); | ||
| return animation.is_valid() && animation.get_loop(); |
| "y": pts[0].y | ||
| }); | ||
| ctx.setLineDash([4, 3]); | ||
| for (let c = 1; pts[0].x + c * period < width && c * n < 10000; c++) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


Depends on mltframework/mlt#1362
This change uses the MLT animation loop feature to allow a user to set up an endless loop keyframe animation.
It adds a new "Loop" button in the keyframe panel. When enabled, the keyframes are looped after the last keyframe.
Looped keyframes are rendered in a shaded color to show them as ghost keyframes. They can't be edited.
Here is an example of the loop being applies to a rotation parameter. The parameter animates from 0-360. However, the way the looping works, the last keyframe is replaced with the first keyframe so it goes to 0 instead of 360.

Here is an example of the loop being applied to a double value. In this case, the last keyframe value is set to the same as the first keyframe so that the value loops seamlessly:

The last keyframe is a special "control" keyframe since it is actually replaced with the value of the first keyframe during interpolation. The right context menu has a convenience action to set it to match the first keyframe for cases where the user wants to do that.